package com.wave.wavesystem.serve.controller;

import com.mybatisflex.core.paginate.Page;
import com.wave.common.model.Result;
import com.wave.wavesystem.serve.pojo.entity.Post;
import com.wave.wavesystem.serve.pojo.query.CenterSearchQuery;
import com.wave.wavesystem.serve.service.IPostService;
import com.wave.wavesystem.serve.service.IUserService;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.*;

import java.util.ArrayList;
import java.util.List;

@RestController
@RequestMapping("/center")
public class SearchController {

    @Resource
    private IPostService postService;

    @Resource
    private IUserService userService;


    @PostMapping("/search")
    public Result<?> search(@RequestBody CenterSearchQuery searchQuery) {
        Page<?> searches =new Page<>();
        if ("post".equals(searchQuery.getSearchType())) {
            searches = postService.search(searchQuery);
        }
        if ("user".equals(searchQuery.getSearchType())) {
            searches = userService.search(searchQuery);

        }
        return Result.success(searches);
    }

}
